﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Jemgine.Engine.Scripts
{
    [Category("Misc"), Node]
    public class PlayAnimation : Data.ScriptNode
    {
        public String Animation { get; set; }

        public PlayAnimation()
        {
            AddInput("Play", null);
            AddOutput("Relay", null);
            AddReference("AnimationComponent", typeof(AnimatedSkeleton));
        }

        public override void FireTerminal(int InputID, Data.ScriptPayload Payload)
        {
            var AC = ReferenceTerminals[0].GetTarget(Payload) as AnimatedSkeleton;
            if (AC != null) AC.Play(Animation, true);
            OutputTerminals[0].Fire(Payload);
        }
    }
}